<template>
	<view class="shipped">
		<view class="shippedItem">
			<view class="topItem">
				<view class="left">
					<image :src="data.httpUrl+'/app/file/viewFile?fileId='+item.storeLogo" mode="aspectFill"></image>
					{{item.storeName}}<text v-if="item.refundCount>0" style="color:red">(售后中)</text>
				</view>
				<view class="right">
					{{item.orderState.name}}
				</view>
			</view>

			<Item v-for="(item1,index1) in item.productDTOS" :key="index1" :item="item1" />
			<view class="logistics" v-for="(item1,index1) in item.emsInfoDTOS.slice(0,1)" :key="index1">
				<view class="left">
					<view class="">
						<image src="/static/img/index/132.png" mode="widthFix"></image>
						{{item1.logisticsStatusDesc || '暂无'}}
					</view>
					<text class="ellipsis_1">{{item1.theLastMessage || '暂无物流'}}</text>

				</view>
				<image src="/static/img/index/58.png" mode="widthFix"></image>
			</view>
			<view class="bot" >
				<text class="lxsj" @tap.stop="contactMerchant(item)">联系商家</text>
				<text @tap.stop="handeSh(item)">确认收货</text>
				<text @tap.stop="handeClick(item)">查看物流信息</text>
				<!-- <text v-if="item.freeOrderFlag.value == 'Y'" class="splicingOrders" @tap.stop="handeClick(item)">邀请好友拼单</text> -->
			</view>
		</view>

	</view>
</template>

<script setup lang="ts">
	//待收货
	import Item from './item'
	import { reactive } from 'vue';
	import { receiveOrder } from '@/utils/api/goods'
	const props = defineProps(['item', 'orderState'])
	const emit = defineEmits(['handeDelete'])
	const data = reactive<any>({
		httpUrl: getApp().globalData.baseUrl,
	})
	const contactMerchant = (item) => {
		const conversationID = `C2C${item.sellUserId}`;
		uni.navigateTo({ url: `/pages/TUIKit/components/TUIChat/index?conversationID=${conversationID}&userId=${item.sellUserId}&trendsId=${item.sonOrderNo}&areaType=order` });
	}
	const handeClick = (item) => {
		uni.navigateTo({
			url: '/pages/logistics/index?id=' + item.sonOrderNo
		})
	}
	const handeSh = (item) => {
		uni.showModal({
			title: '提示',
			content: '是否收货?',
			success: (e) => {
				if (e.confirm) {
					receiveOrder({ data: { sonOrderNo: item.sonOrderNo } }).then((res) => {
						console.log(res, 'ress')
						if (res.code == 200) {
							uni.showToast({
								title: '收货成功!',
								icon: 'none'
							})
							item.orderState.value = 'COMPLETE'
							item.evaluationStatus.value = 'WAIT_EVALUATE'
							// if(props.orderState){
							// 	emit('handeDelete')
							// }else{
							// 	item.orderState.value = 'COMPLETE'
							// }
						}
					})
				}
			}
		})
	}
</script>

<style lang="scss">
	.shipped {
		.shippedItem {
			margin-top: 20rpx;
		}

		.logistics {
			padding: 16rpx;
			border-radius: 16rpx;
			background: #F4F6FA;
			display: flex;
			align-items: center;
			margin-top: 24rpx;

			>image {
				width: 40rpx;
			}

			.left {
				flex: 1;
				margin-right: 20rpx;
				display: flex;
				flex-direction: column;
				width: 0;

				image {
					width: 48rpx;
					margin-right: 10rpx;
				}

				view {
					margin-bottom: 10rpx;
					display: flex;
					align-items: center;
				}

				text {
					font-size: 24rpx;
					color: #595959;
					width: 100%;
				}
			}
		}

		>.bot1 {
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 24rpx;
			color: #8C8C8C;
			margin-top: 25rpx;

			view {
				font-size: 24rpx;

				text {
					font-size: 36rpx;
					color: #6B64D3;
				}
			}
		}

		.bot {
			margin-top: 33rpx;
			display: flex;
			align-items: flex-end;
			justify-content: flex-end;

			text {
				padding: 11rpx 24rpx;
				border-radius: 100rpx;
			}

			text:nth-of-type(1) {
				border: 2rpx solid #D9D9D9;
				margin-right: 16rpx;
			}

			text:nth-of-type(2) {
				color: #6B64D3;
				border: 2rpx solid #6B64D3;
				margin-right: 16rpx;
			}
			
			text:nth-of-type(3) {
				border: 2rpx solid #94bcff;
			}
		}

		.topItem {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.left {
				display: flex;
				align-items: center;
				font-size: 32rpx;

				.lxsj {
					padding: 5rpx 10rpx;
					border-radius: 100rpx;
					border: 2rpx solid #D9D9D9;
					margin-left: 10rpx;
				}

				image {
					width: 48rpx;
					height: 48rpx;
					border-radius: 50%;
					margin-right: 16rpx;
				}
			}

			.right {
				color: #FF8C00;
			}
		}
	}
	.splicingOrders{
		color: #fff;
		border-color: #FF263F!important;
		background-color: #FF263F;
	}
</style>